//Tags: SegmentTree
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>

typedef long long ll;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 2e5 + 5, mod = 1e9 + 7;
int n, m, b[N], k[N];

struct Node {
  ll sum, k;
  Node() {}
  Node(const ll &sum, const ll &k) : sum(sum), k(k) {}

  inline void operator+=(const Node &rhs) {
    if ((sum *= rhs.k) >= mod) sum %= mod;
    if ((sum += rhs.sum) >= mod) sum -= mod;
    if ((k *= rhs.k) >= mod) k %= mod;
  }

  inline ll operator()(const int &x) { return (k * x % mod + sum) % mod; }

} tr[N << 2];

inline void pushup(int x) {
  tr[x].k = tr[x << 1].k * tr[x << 1 | 1].k % mod;
  tr[x].sum =
      (tr[x << 1].sum * tr[x << 1 | 1].k % mod + tr[x << 1 | 1].sum) % mod;
}

void build(int x, int l, int r) {
  if (l == r) { return tr[x] = Node(b[l], k[l]), void(); }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  pushup(x);
}

void modify(int x, int l, int r, int p, ll k, ll b) {
  if (l == r) { return tr[x] = Node(b, k), void(); }
  int mid = (l + r) >> 1;
  if (p <= mid) modify(x << 1, l, mid, p, k, b);
  else
    modify(x << 1 | 1, mid + 1, r, p, k, b);
  pushup(x);
}

Node query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return tr[x];
  int mid = (l + r) >> 1;
  Node res(0, 1);
  if (L <= mid) res += query(x << 1, l, mid, L, R);
  if (mid < R) res += query(x << 1 | 1, mid + 1, r, L, R);
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("linermath.in", "r", stdin);
  freopen("linermath.out", "w", stdout);
#endif
#endif

  char opt[5];
  read(n), read(m);
  for (int i = 1; i <= n; i++) scanf("%d%d", &k[i], &b[i]);
  build(1, 1, n);
  for (int i = 1, x, l, r; i <= m; i++) {
    scanf("%s", opt);
    if (opt[0] == 'M') {
      ll K, B;
      scanf("%d%lld%lld", &x, &K, &B);
      modify(1, 1, n, x, K, B);
    } else {
      ll x;
      scanf("%d%d%lld", &l, &r, &x);
      printf("%lld\n", query(1, 1, n, l, r)(x));
    }
  }
  return 0;
}